package com.example.demo.utils.webSocketUtils

import java.lang.Enum
import java.util.*


class SessionDescription(val type: Type, val description: String) {
    val typeInCanonicalForm: String
        get() = type.canonicalForm()

    enum class Type {
        OFFER, PRANSWER, ANSWER;

        fun canonicalForm(): String {
            return name.toLowerCase(Locale.US)
        }

        companion object {
            fun fromCanonicalForm(canonical: String): Type {
                return Enum.valueOf(Type::class.java, canonical.toUpperCase(Locale.US)) as Type
            }
        }
    }
}
